package com.wiscamp.ninechapters.accounts.infrastructure.mappers;

import com.wiscamp.ninechapters.accounts.infrastructure.po.AccountBatchPO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.Collection;

@Component
public interface AccountBatchMapper extends JpaRepository<AccountBatchPO, Long>, JpaSpecificationExecutor<AccountBatchPO> {

    @Query(value = "select e from AccountBatchPO e where e.accountId = :accountId and e.accountType = :accountType and e.userId = :userId and e.balance > 0 order by e.batchNumber")
    Collection<AccountBatchPO> getAccountBatches(long accountId, int accountType, long userId);
}